// test_module_constroller.cpp : Defines the entry point for the console application.
//

#include <memory>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include "module_controller.h"


namespace ModuleManagement
{
	class TestModule : public BaseModule
	{
	public:
		TestModule()
		{
			std::cout << "TestModule constructor\n";
		}
		~TestModule()
		{
			std::cout << "TestModule destructor\n";
		}
		virtual Common::Error RunLogic()
		{
			return Common::SKYPE_SUCCESS;
		}
		virtual Common::Error BeforeRun()
		{
			return Common::SKYPE_SUCCESS;
		}
		virtual Common::Error AfterRun()
		{
			return Common::SKYPE_SUCCESS;
		}
	};
}



int main(int argc, char* argv[])
{
	using namespace ModuleManagement;
	std::auto_ptr<ModuleController> controller = CreateModuleController();
	if (!controller.get())
		std::cout << "Error: Unable to create module controller\n";
	else
	{
		std::auto_ptr<TestModule> module(new TestModule());

		// register
		size_t ID;
		if (controller->RegisterModule(module.release(), ID) != Common::SKYPE_SUCCESS)
			std::cout << "Error: Unable to register module\n";
		//module.release();
		//module.reset(0);

		const TestModule* obj = static_cast<const TestModule*>(controller->GetModuleByID(ID));

		// unregister
		if (controller->UnregisterModule(ID) != Common::SKYPE_SUCCESS)
			std::cout << "Error: Unable to unregister module\n";
	}

	getch();
	return 0;
}

